﻿/*
 * 版 本 PIT-ADMS V7.0.3 敏捷开发框架
 * Copyright (c) 2013-2018 Hexagon PPM
 * 创建人：研发部
 * 日 期：2020.04.03
 * 描 述：复制流程模板	
 */
var categoryId = request('categoryId');
var ProjectId = request('ProjectId');
var acceptClick;
var learunAll;
var auditorName = '';
var bootstrap = function ($, learun) {
    "use strict";
    learunAll = learun;
    var page = {
        init: function () {
            $('#F_Name').lrselect({
                value: 'F_Id',
                text: 'F_Name',
                title: 'F_Name',
                // 展开最大高度
                maxHeight: 190,
                // 是否允许搜索
                allowSearch: true,
            });
            // 流程分类
            $('#F_Category').lrDataItemSelect({
                code: 'FlowSort'
            }).on('change', function () {
                var value = $(this).lrselectGet();
                $('#F_Name').lrselectRefresh({
                    url: top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/GetNWFSchemeInfoList',
                    param: { category: value }
                });
            });
            $('#F_Category').lrselectSet(categoryId);    
        }
    };
    // 保存数据
    acceptClick = function (callBack) {
        if (!$('#form').lrValidform()) {
            return false;
        }
        $('#F_Id').val(Guid.NewGuid().toString());
        $('#F_SchemeId').val(Guid.NewGuid().toString());
        var keyValue=$('#F_Name').lrselectGet();
        $('#ProjectId').val(ProjectId);    
        var formData = $('#form').lrGetFormData();
        var postData = JSON.stringify(formData);


        $.ajax({
            type: 'POST',
            url: top.$.rootUrl + "/LR_NewWorkFlow/NWFScheme/CopyForm?rdo=" + Math.random(),
            data: { keyValue: keyValue, newSchemeInfo: postData },
            traditional: true,
            success: function (data) {
                var data = JSON.parse(data);
                if (data.code == '200') {
                    learun.frameTab.currentIframe().refreshGirdData();
                }
            },
            error: function (msg) {
            }, complete: function (data) {
            }
        });
    };
    page.init();
}